// Hooks added here have a bridge allowing communication between the BEX Content Script and the Quasar Application.
// More info: https://quasar.dev/quasar-cli/developing-browser-extensions/content-hooks

import { bexContent } from 'quasar/wrappers'

// const dom = document.getElementById('sb_form_q')
// console.log('===dom', dom)


export default bexContent((bridge) => {
  bridge.on('page_add_btn', ({respond }) => {
    console.log('my-contents.js脚本')
    var newElement = document.createElement("h3");
    // 设置新元素的文本内容
    newElement.innerHTML = "添加内容";
    // 获取body元素
    var body = document.getElementsByTagName("body")[0];
    // 在body的第一个子元素之前插入新元素
    body.insertBefore(newElement, body.firstChild);

   // 调用backgruond.js
    bridge.send('log', {message: 'contens.js调用backgound.js'}) 
    alert('====content.js')
    bridge.send('message')

    // const dom = document.getElementsByTagName('body').
    // console.log(dom)
    respond()
  })
})
